package com.healthy.education.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.healthy.common.log.annotation.Log;
import com.healthy.common.log.enums.BusinessType;
import com.healthy.common.security.annotation.RequiresPermissions;
import com.healthy.education.domain.Venues;
import com.healthy.education.service.IVenuesService;
import com.healthy.common.core.web.controller.BaseController;
import com.healthy.common.core.web.domain.AjaxResult;
import com.healthy.common.core.utils.poi.ExcelUtil;
import com.healthy.common.core.web.page.TableDataInfo;

/**
 * 活动场地Controller
 * 
 * @author 束伟
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/Venues")
public class VenuesController extends BaseController
{
    @Autowired
    private IVenuesService venuesService;

    /**
     * 查询活动场地列表
     */
    @RequiresPermissions("education:Venues:list")
    @GetMapping("/list")
    public TableDataInfo list(Venues venues)
    {
        startPage();
        List<Venues> list = venuesService.selectVenuesList(venues);
        return getDataTable(list);
    }

    /**
     * 导出活动场地列表
     */
    @RequiresPermissions("education:Venues:export")
    @Log(title = "活动场地", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Venues venues)
    {
        List<Venues> list = venuesService.selectVenuesList(venues);
        ExcelUtil<Venues> util = new ExcelUtil<Venues>(Venues.class);
        util.exportExcel(response, list, "活动场地数据");
    }

    /**
     * 获取活动场地详细信息
     */
    @RequiresPermissions("education:Venues:query")
    @GetMapping(value = "/{venueId}")
    public AjaxResult getInfo(@PathVariable("venueId") Long venueId)
    {
        return success(venuesService.selectVenuesByVenueId(venueId));
    }

    /**
     * 新增活动场地
     */
    @RequiresPermissions("education:Venues:add")
    @Log(title = "活动场地", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Venues venues)
    {
        return toAjax(venuesService.insertVenues(venues));
    }

    /**
     * 修改活动场地
     */
    @RequiresPermissions("education:Venues:edit")
    @Log(title = "活动场地", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Venues venues)
    {
        return toAjax(venuesService.updateVenues(venues));
    }

    /**
     * 删除活动场地
     */
    @RequiresPermissions("education:Venues:remove")
    @Log(title = "活动场地", businessType = BusinessType.DELETE)
	@DeleteMapping("/{venueIds}")
    public AjaxResult remove(@PathVariable Long[] venueIds)
    {
        return toAjax(venuesService.deleteVenuesByVenueIds(venueIds));
    }
}
